package cn.easybuy.entity;

import java.util.Date;
import java.util.List;
import java.util.UUID;

public class Order {
    private Integer id;//ID
    private Integer userId;//用户id
    private String loginName;//用户名
    private String userAddress;//收货地址
    private Date createTime;//创建时间
    private Float cost;//订单总计价格
    private String serialNumber;//订单号
    private List<OrderShow> productList;//订单详情

    public Order(){

    }

    public Order(int id,String loginName, String userAddress, Float cost, String serialNumber) {
        this.id = id;
        this.loginName = loginName;
        this.userAddress = userAddress;
        this.cost = cost;
        this.serialNumber = serialNumber;
    }

    public Order(Integer id, Integer userId, String loginName, String userAddress, Date createTime, Float cost, String serialNumber) {
        this.id = id;
        this.userId = userId;
        this.loginName = loginName;
        this.userAddress = userAddress;
        this.createTime = createTime;
        this.cost = cost;
        this.serialNumber = serialNumber;
    }

    public Order(Integer id, Integer userId, String loginName, String userAddress, Date createTime, Float cost, String serialNumber, List<OrderShow> productList) {
        this.id = id;
        this.userId = userId;
        this.loginName = loginName;
        this.userAddress = userAddress;
        this.createTime = createTime;
        this.cost = cost;
        this.serialNumber = serialNumber;
        this.productList = productList;
    }

    public List<OrderShow> getProductList() {
        return productList;
    }

    public void setProductList(List<OrderShow> productList) {
        this.productList = productList;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getUserAddress() {
        return userAddress;
    }

    public void setUserAddress(String userAddress) {
        this.userAddress = userAddress;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Float getCost() {
        return cost;
    }

    public void setCost(Float cost) {
        this.cost = cost;
    }

    public String getSerialNumber() {
        if (serialNumber==null || serialNumber.equals("")){
            serialNumber = UUID.randomUUID().toString().replace("-","").toUpperCase();
        }
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    @Override
    public String toString() {
        return "Order{" +
                "id=" + id +
                ", userId=" + userId +
                ", loginName='" + loginName + '\'' +
                ", userAddress='" + userAddress + '\'' +
                ", createTime=" + createTime +
                ", cost=" + cost +
                ", serialNumber='" + serialNumber + '\'' +
                '}';
    }
}
